﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;
using HotelManagement._04.OBJECT;
using CrystalDecisions.Shared;

namespace HotelManagement._03.DAO
{
    class ReportCustomerServiceDAO
    {
        DbConnection m_conn;
        SqlCommand m_command;
        SqlDataAdapter m_adap;

        public ReportCustomerServiceDAO()
        {
            m_conn = new DbConnection();
        }
        public DataTable ViewReportCustomerService(DateTime ip_FromDate,DateTime ip_ToDate,string ip_procedure)
        {
            m_command = new SqlCommand(ip_procedure, m_conn.Connect());
            m_command.CommandType = CommandType.StoredProcedure;
            m_command.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = ip_FromDate;
            m_command.Parameters.Add("@ToDate", SqlDbType.DateTime).Value = ip_ToDate;
            DataTable v_dt = new DataTable();
            m_adap = new SqlDataAdapter(m_command);
            try
            {
                m_adap.Fill(v_dt);
                m_conn.Close();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
            return v_dt;

        }
        public ParameterFields AddParameter(DateTime ip_FromDate, DateTime ip_ToDate)
        {
            ParameterFields v_Para = new ParameterFields();
            ParameterField v_ParamField1 = new ParameterField();
            ParameterDiscreteValue v_ParamDiscreteValue1 = new ParameterDiscreteValue();
            ParameterValues v_ParamValues1 = new ParameterValues();

            // Set the name of the parameter to modify.
            v_ParamField1.ParameterFieldName = "@FromDate";

            // Set a value to the parameter.
            ////paramDiscreteValue.Value = m_txt_tim.Text;
            v_ParamDiscreteValue1.Value = ip_FromDate;
            v_ParamValues1.Add(v_ParamDiscreteValue1);
            v_ParamField1.CurrentValues = v_ParamValues1;
            v_Para.Add(v_ParamField1);

            //field 2
            ParameterField v_ParamField2 = new ParameterField();
            ParameterDiscreteValue v_ParamDiscreteValue2 = new ParameterDiscreteValue();
            ParameterValues v_ParamValues2 = new ParameterValues();

            // Set the name of the parameter to modify.
            v_ParamField2.ParameterFieldName = "@ToDate";

            // Set a value to the parameter.
            ////paramDiscreteValue.Value = m_txt_tim.Text;
            v_ParamDiscreteValue2.Value = ip_ToDate;
            v_ParamValues2.Add(v_ParamDiscreteValue2);
            v_ParamField2.CurrentValues = v_ParamValues2;
            v_Para.Add(v_ParamField2);

            return v_Para;
        }

    }
}
